package com.meicet.adapter.adapter

import androidx.annotation.Keep

// 多类型适配  继承BaseMultiMode
// 这个适合监听 视频播放器 的生命周期
@Keep
open class BaseMultiModeAttachAdapter(list: MutableList<BaseMultiMode>? = null, useDecoration: Boolean = false) :
    BaseMultiModeAdapter(list, useDecoration) {

    override fun onViewAttachedToWindow(holder: BaseHolder) {
        super.onViewAttachedToWindow(holder)
        val position = holder.bindingAdapterPosition - headerLayoutCount
        if (position >= 0 && data.isNotEmpty()) {
            val index = findIndexByPosition(position)
            data[index].onViewAttachedToWindow(holder, position)
        }
    }

    override fun onViewDetachedFromWindow(holder: BaseHolder) {
        super.onViewDetachedFromWindow(holder)
        val position = holder.bindingAdapterPosition - headerLayoutCount
        if (position >= 0 && data.isNotEmpty()) {
            val index = findIndexByPosition(position)
            data[index].onViewDetachedFromWindow(holder, position)
        }
    }
}
